program GCD(input,output);
var n,i,x,y:integer;
function gcd(a,b:integer):integer;
begin
	if b=0 then gcd:=a
	else gcd:=gcd(b,a mod b);
end;
begin
    read(n);
    for i:= 1 to n do
    begin
        read(x,y);
        writeln(gcd(x,y))
    end;
end.